package com.wing.visual.controller;

import com.wing.common.utils.JsonResult;
import com.wing.visual.service.WarehouseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * 仓库可视化
 *
 * @author xiayang
 */
@Validated
@Api(value = "仓库可视化管理", tags = "#/visual/warehouse")
@RestController("visualWarehouseController")
@RequestMapping("visual/admin/warehouse")
public class WarehouseController {

    @Resource
    WarehouseService warehouseService;

    @ApiOperation(value = "仓库物资总额统计", notes = "仓库物资总额统计")
    @GetMapping("/warehouseMaterialAmountTotal")
    public JsonResult warehouseMaterialAmountTotal() {
        return JsonResult.success(warehouseService.warehouseMaterialAmountTotal());
    }

    @ApiOperation(value = "库存物资汇总", notes = "库存物资汇总")
    @GetMapping("/inventoryMaterialTotal")
    public JsonResult inventoryMaterialTotal() {
        return JsonResult.success(warehouseService.inventoryMaterialTotal());
    }

    @ApiOperation(value = "仓库类型统计", notes = "仓库类型统计")
    @GetMapping("/warehouseTypeTotal")
    public JsonResult warehouseTypeTotal() {
        return JsonResult.success(warehouseService.warehouseTypeTotal());
    }

    @ApiOperation(value = "入库物料统计", notes = "入库物料统计")
    @GetMapping("/warehouseInStorageTotal")
    public JsonResult warehouseInStorageTotal() {
        Map<String, Object> params = new HashMap<>();
        params.put("inventoryType", 1);
        return JsonResult.success(warehouseService.warehouseInoutStorageTotal(params));
    }

    @ApiOperation(value = "出库物料统计", notes = "出库物料统计")
    @GetMapping("/warehouseOutStorageTotal")
    public JsonResult warehouseOutStorageTotal() {
        Map<String, Object> params = new HashMap<>();
        params.put("inventoryType", 2);
        return JsonResult.success(warehouseService.warehouseInoutStorageTotal(params));
    }

    @ApiOperation(value = "出入库单量统计", notes = "出入库单量统计")
    @GetMapping("/inoutStorageOrderTotal")
    public JsonResult inoutStorageOrderTotal() {
        return JsonResult.success(warehouseService.inoutStorageOrderTotal());
    }

}
